﻿#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

vector<string> readFileIntoVector(const string& filename);

int main() {
	vector<string> lines = readFileIntoVector("example.txt"); // 文件名为 example.txt
	for (const string& line : lines) {
		cout << line << endl;
	}
	return 0;
}

// 函数定义
vector<string> readFileIntoVector(const string& filename) {
	ifstream file(filename);
	if (!file.is_open()) {
		throw runtime_error("Failed to open file: " + filename);
	}
	vector<string> result;
	string line;
	while (getline(file, line)) {
		result.push_back(line);
	}
	file.close();
	return result;
}

